<template>
  <div class="componentPage">
    <!-- 蒙版动态显示 -->
    <div class="hazy-container">
      <h2 style="text-align: center;">把鼠标悬浮在图片上</h2>
      <div class="hazy-content">
        <img width="90%" height="100%"  src="./sweet_font.jpg" alt="图片加载失败">
        <div class="overlap">
          <span>这是棒棒糖正面</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name:'HazyDisplay',
}
</script>

<style lang='less' scoped>
  .componentPage {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .hazy-container {
      width: 80%;
      height: 90%;
      position: relative;
      min-width: 50px;
      min-height: 50px;
      overflow: hidden;
      .hazy-content {
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        img {
          transition: all 0.5s ease-in-out;
        }
        .overlap {
          position: absolute;
          top: 0;
          bottom: 0;
          right: 0;
          left: 0;
          padding-top: 0;
          font-size: 12px;
          text-align: center;
          color: transparent;/*将背景变为透明*/
          transition: all 0.5s ease;
        }
      }
      .hazy-content:hover {
        img {
          transform: scale(1.3, 1.3);
        }
        .overlap {
          color: #efe;
          font-size: 18px;
          background-color: rgba(0,0,0,0.6);
          display: flex;
          justify-content: center;
          align-items: center;
        }
      } 
    }
    
  }
</style>